/*
 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
 * openFuyao is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

package pkiutil

import (
	"path/filepath"
	"time"
)

const (
	// TLSKeyDataName use to store a TLS private key in secret's data field.
	TLSKeyDataName = "tls.key"

	// TLSCrtDataName  use to store a TLS certificate in secret's data field.
	TLSCrtDataName = "tls.crt"

	// TempDirForKubeadm define temporary directory for kubeadm.
	TempDirForKubeadm = "tmp"
	// CertDirName define directory name to store certificates.
	CertDirName = "pki"

	// DefaultRSAKeySize default size of the RSA key.
	DefaultRSAKeySize = 2048

	// CertificateValidity define the validity for signed certificates generated by kubeadm.
	CertificateValidity = time.Hour * 24 * 365 * 10

	// CACertCommonName define certificate common name (CN).
	CACertCommonName = "kubernetes"

	// AdminKubeConfigFileName define name for the kubeconfig.
	AdminKubeConfigFileName = "admin"

	// LocalKubeConfigFileName define name for the kubeconfig.
	LocalKubeConfigFileName = "kubeconfig"

	// KubeletKubeConfigFileName define the file name for the kubeconfig.
	KubeletKubeConfigFileName = "kubelet"
	// ControllerManagerKubeConfigFileName define the file name for the controller manager's kubeconfig.
	ControllerManagerKubeConfigFileName = "controller-manager"
	// SchedulerKubeConfigFileName define the file name for the scheduler's kubeconfig.
	SchedulerKubeConfigFileName = "scheduler"

	// CoreDNSImageName specify the name of the image for CoreDNS add-on.
	CoreDNSImageName = "coredns/coredns"

	// PauseVersion indicate the default pause image version.
	PauseVersion = "3.4.1"
)

func GetDefaultPkiPath() string {
	return filepath.Join(KubernetesDir, CertDirName)
}

func GetDefaultEtcdPkiPath() string {
	return filepath.Join(GetDefaultPkiPath(), "etcd")
}

func GetDefaultKubeConfigPath() string {
	return filepath.Join(KubernetesDir, AdminKubeConfigFileName+".conf")
}
